#include "fx_chorus.h"
#include "ui_fx_chorus.h"

fx_chorus::fx_chorus(QWidget *parent) :
    fx_basic(parent),
    ui(new Ui::fx_chorus)
{
    ui->setupUi(this);

    QStringList wave_form;
    wave_form << "Triangle" << "Sine";
    ui->comboBox_wave->addItems(wave_form);
    ui->comboBox_wave->setCurrentIndex(1);

    QStringList phase;
    phase << "-180" << "-90" << "0" << "90" << "180";
    ui->comboBox_phase->addItems(phase);
    ui->comboBox_phase->setCurrentIndex(3);
}

fx_chorus::~fx_chorus()
{
    delete ui;
}

void fx_chorus::feed(int value)
{
    ui->label_feed->setText(QString::number(value));
}

void fx_chorus::depth(int value)
{
    ui->label_depth->setText(QString::number(value));
}

void fx_chorus::wet(int value)
{
    ui->label_wet->setText(QString::number(value));
}

void fx_chorus::freq(int value)
{
    ui->label_freq->setText(QString::number(double(value) / 10));
}

void fx_chorus::delay(int value)
{
    ui->label_delay->setText(QString::number(value));
}

void fx_chorus::addFX()
{
    BASS_DX8_CHORUS* result = new BASS_DX8_CHORUS();
    result->fDelay = ui->horizontalSlider_delay->value();
    result->fDepth = ui->horizontalSlider_depth->value();
    result->fFeedback = ui->horizontalSlider_feed->value();
    result->fFrequency = float(ui->horizontalSlider_frequency->value()) / 10;
    result->fWetDryMix = ui->horizontalSlider_wet->value();
    result->lWaveform = ui->comboBox_wave->currentIndex();
    int index = ui->comboBox_phase->currentIndex();
    if (index == 0)
        result->lPhase = BASS_DX8_PHASE_NEG_180;
    else if (index == 1)
        result->lPhase = BASS_DX8_PHASE_NEG_90;
    else if (index == 2)
        result->lPhase = BASS_DX8_PHASE_ZERO;
    else if (index == 3)
        result->lPhase = BASS_DX8_PHASE_90 ;
    else
        result->lPhase = BASS_DX8_PHASE_180;
    emit apply(BASS_FX_DX8_CHORUS, result);
}
